//计算并显示游戏得分




function Mark(pV, bR)
{
	var _this = this;
	
	_this.position = pV;
	_this.box = bR;
	_this.ready = false;
	_this.count = undefined;
	_this.imgList = undefined;
	_this.imgSrc_ = ["./images/num0.png",
					 "./images/num1.png",
					 "./images/num2.png",
					 "./images/num3.png",
					 "./images/num4.png",
					 "./images/num5.png",
					 "./images/num6.png",
					 "./images/num7.png",
					 "./images/num8.png",
					 "./images/num9.png"
					 ];
					 
	_this.imgSrc_G = ["./images/num0_.png",
					 "./images/num1_.png",
					 "./images/num2_.png",
					 "./images/num3_.png",
					 "./images/num4_.png",
					 "./images/num5_.png",
					 "./images/num6_.png",
					 "./images/num7_.png",
					 "./images/num8_.png",
					 "./images/num9_.png"
					 ];
	
	var MarkNode = function(pV, bR)
	{
		var _this = this;
		Sprite.call(_this, pV, bR);
		_this.img = undefined;
		_this.position = pV;
		_this.box = bR;
		
	    _this.draw = function(canvas)
		{
			var context = canvas.getContext("2d");
			context.drawImage(_this.img, _this.position.x, _this.position.y);		
		}
		
		_this.update = function()
		{
			_this.position = _this.physicsNode.position;
		}
		
		var init = function()
		{
			_this.img = new Image();
			_this.physicsNode = new PhysicsNode(pV, bR, new Vector2(0, 0), new Vector2(0, 0));
		}
		init();
	}
	inheritPrototype(MarkNode, Sprite);
		
	_this.CreateImgList = function(marks,imgSrc)
	{	
		var tmp;
		do{
			tmp = parseInt(marks % 10);
			//alert(tmp);
			var node = new MarkNode(new Vector2(0,0), new Rectangle(0,0));
			//alert("da");
			switch (tmp)
			{
				case 0:
					node.img.src = imgSrc[0];
					_this.imgList.push(node);
					break;
				case 1:
					node.img.src = imgSrc[1];
					_this.imgList.push(node);
					break;
				case 2:
					node.img.src = imgSrc[2];
					_this.imgList.push(node);
					break;
				case 3:
					node.img.src = imgSrc[3];
					_this.imgList.push(node);
					break;
				case 4:
					node.img.src = imgSrc[4];
					_this.imgList.push(node);
					break;
				case 5:
					node.img.src = imgSrc[5];
					_this.imgList.push(node);
					break;
				case 6:
					node.img.src = imgSrc[6];
					_this.imgList.push(node);
					break;
				case 7:
					node.img.src = imgSrc[7];
					_this.imgList.push(node);
					break;
				case 8:
					node.img.src = imgSrc[8];
					_this.imgList.push(node);
					break;
				case 9:
					node.img.src = imgSrc[9];
					_this.imgList.push(node);
					break;	
			}
				
			marks = parseInt(marks / 10);
	
		}while(marks != 0)
		
		_this.imgList[0].position.x = _this.position.x;
		_this.imgList[0].position.y = _this.position.y;
		for(var i = 1; i < _this.imgList.length; i++)
		{
			_this.imgList[i].position.x = _this.imgList[i-1].position.x	- _this.box.width;
			_this.imgList[i].position.y = _this.imgList[i-1].position.y;
		}
		
		return _this.imgList;
	}
	
	_this.FreeImgList = function()
	{
		while(_this.imgList.length > 0)
		{
			_this.imgList.pop();
		}
	}
	
	_this.imgLoadCallBack = function()
	{
		// 如果所有图片加载完成, 那么设置ready为真
		_this.count += 1;

		if(_this.count == _this.imgSrc_.length)
		{
			_this.ready = true;
		}
		return true;
	}
	
	var init = function()
	{
		_this.imgList = new Array();
		for(var i = 0; i < _this.imgList.length; i++)
		{
			_this.imgList[i].img = new Image();
			_this.imgList[i].img.src = _this.imgSrc_[0];
			// 设置图片的完成回调函数, 用于完成资源的载入调度
			img.onload = _this.imgLoadCallBack;
		}
	}
	init();
}